package com.googlecode.wmlynar.gwtbeans.gen;

import com.thoughtworks.qdox.model.BeanProperty;

/**
 * 
 * @author Wojciech Mlynarczyk (wmlynar@gmail.com)
 * 
 */
public class PropertyAccessor {

    private String className;
    private String propertyClassName;
    private String propertyName;
    private BeanProperty property;

    public PropertyAccessor(final String className, final String propertyClassName,
            final String propertyName, final BeanProperty property) {
        super();
        this.className = className;
        this.propertyClassName = propertyClassName;
        this.propertyName = propertyName;
        this.property = property;
    }

    public final String getClassName() {
        return className;
    }

    public final void setClassName(final String className) {
        this.className = className;
    }

    public final String getPropertyClassName() {
        return propertyClassName;
    }

    public final void setPropertyClassName(final String propertyClassName) {
        this.propertyClassName = propertyClassName;
    }

    public final String getPropertyName() {
        return propertyName;
    }

    public final void setPropertyName(final String propertyName) {
        this.propertyName = propertyName;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((className == null) ? 0 : className.hashCode());
        result = prime * result + ((propertyClassName == null) ? 0 : propertyClassName.hashCode());
        result = prime * result + ((propertyName == null) ? 0 : propertyName.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PropertyAccessor other = (PropertyAccessor) obj;
        if (className == null) {
            if (other.className != null) {
                return false;
            }
        } else if (!className.equals(other.className)) {
            return false;
        }
        if (propertyClassName == null) {
            if (other.propertyClassName != null) {
                return false;
            }
        } else if (!propertyClassName.equals(other.propertyClassName)) {
            return false;
        }
        if (propertyName == null) {
            if (other.propertyName != null) {
                return false;
            }
        } else if (!propertyName.equals(other.propertyName)) {
            return false;
        }
        return true;
    }

    public void setProperty(final BeanProperty property) {
        this.property = property;
    }

    public BeanProperty getProperty() {
        return property;
    };

}
